﻿using System.Drawing;
using System.Drawing.Drawing2D;

namespace MathService.Functions.Plotter.GraphComponents
{
    public class AxisLine : IGraphElement
    {
        private readonly Graph parentGraph;

        public AxisLine(Graph parentGraph) { this.parentGraph = parentGraph; }

        #region IGraphElement Members

        public void Draw(Graphics graphics)
        {
            graphics.SetClip(parentGraph.ClientRectangle);
            var pen = new Pen(new SolidBrush(parentGraph.YAxisColor), 2f)
                          {
                                      EndCap = LineCap.ArrowAnchor
                          };
            RectangleF graphArea = parentGraph.GraphArea;
            graphics.DrawLine(pen, graphArea.Left, graphArea.Bottom, graphArea.Left, graphArea.Top);
            pen.Color = parentGraph.XAxisColor;
            pen.EndCap = LineCap.ArrowAnchor;
            graphics.DrawLine(pen, graphArea.Left, graphArea.Bottom, graphArea.Right, graphArea.Bottom);
            pen.Dispose();
        }

        #endregion
    }
}
